package com.gzyj.jtt808.v2013.model.position.additionalInfo;


import com.gzyj.jtt808.utils.HexBytesUtil;
import com.gzyj.jtt808.v2011.additionalinfo.JTT808_AddtionalInfo;
import io.netty.buffer.ByteBuf;
import lombok.Data;

import java.io.Serializable;

/**
 * 需要人工确认报警事件的 ID
 * @author lhj
 */
@Data
public class JTT808_0x0200_0x04 extends JTT808_AddtionalInfo implements Serializable {


    private Integer EventId;

    public JTT808_0x0200_0x04(){
        this.setID(0x04);
        this.setLength(2);
    }

    @Override
    public void encode(ByteBuf buf) {
        buf.writeByte(this.getID());
        buf.writeByte(this.getLength());
        buf.writeShort(this.EventId);
    }

    @Override
    public JTT808_0x0200_0x04 decode(ByteBuf buf) {
        byte[] temp= HexBytesUtil.readByOffset(buf,1);
        this.setLength(Integer.parseInt(HexBytesUtil.bytesToHex(temp),16));
        this.EventId= buf.readUnsignedShort();
        return this;
    }


}
